﻿using Verbose = KinonekoSoftware.Studio.Messages.Verbose;

namespace KinonekoSoftware.Studio.ViewModels
{
    partial class AppViewModel
    {
        
        
        protected override bool OnKeyboardRouting(int key, int modifier, bool isUp)
        {
            if (!isUp)
            {
                return false;
            }

            if (modifier == KeyboardModifierConstants.Control)
            {
                MessageCore msg = key switch
                {
                    uKey.S   => new CommandMessage { Verbose = Verbose.Save },
                    uKey.N   => new CommandMessage { Verbose = Verbose.New },
                    uKey.Z   => new CommandMessage { Verbose = Verbose.Undo },
                    uKey.Y   => new CommandMessage { Verbose = Verbose.Redo },
                    uKey.O   => new CommandMessage { Verbose = Verbose.Open },
                    _        => null,
                };


                if (msg is not null)
                {
                    (Current as IMessageBus<MessageCore>)?.OnNext(msg);
                    return true;
                }
            }

            //
            // Ctrl + Shift
            if (modifier == (KeyboardModifierConstants.Control | KeyboardModifierConstants.Shift))
            {
                switch (key)
                {
                    case uKey.I:
                        GotoSetting();
                        break;
                    default:
                        break;
                }

                var msg = key switch
                {
                    uKey.I => new CommandMessage { Verbose = Verbose.OpenSetting },
                    _     => null,
                };


                if (msg is not null)
                {
                    (Current as IMessageBus<MessageCore>)?.OnNext(msg);
                    return true;
                }
            }

            return false;
        }


    }
}